<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWxMaterialNew extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_material_news', function (Blueprint $table) {
            $table->increments('new_id')->comment('图文ID');
            $table->unsignedInteger('material_id')->comment('素材主键');
            $table->string('title', 150)->default('')->comment('标题');
            $table->unsignedInteger('thumb_material_id')->default(0)->comment('封面图素材主键');
            $table->string('thumb_media_id', 150)->default('')->comment('封面图素材ID');
            $table->string('thumb_view_url', 200)->default('')->comment('封面图访问地址');
            $table->string('author', 50)->default('')->comment('作者');
            $table->string('digest', 200)->comment('图文消息的摘要，仅有单图文消息才有摘要，多图文此处为空');
            $table->unsignedTinyInteger('show_cover_pic')->default(0)->comment('是否显示封面，0为false，即不显示，1为true，即显示');
            $table->text('content')->comment('图文消息的具体内容');
            $table->string('content_source_url', 250)->default('')->comment('图文消息的原文地址，点击“阅读原文”后的URL');
            $table->string('news_click_url', 250)->default('')->comment('图文点击跳转地址');
            $table->unsignedTinyInteger('need_open_comment')->default(0)->comment('是否打开评论(0:不打开,1:打开)');
            $table->unsignedTinyInteger('only_fans_can_comment')->default(0)->comment('是否粉丝才可评论(0:所有人可评论,1:粉丝才可评论)');
            $table->unsignedSmallInteger('order_num')->default(0)->comment('排序数字');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['material_id','deleted_at','order_num'],'index1');
            $table->index(['material_id','order_num','deleted_at'],'index2');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_material_news');
    }
}
